<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>新增站点信息</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/plugins/jQuery/themes/default/easyui.css"/>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/plugins/jQuery/themes/icon.css"/>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/plugins/jQuery/demo.css"/>
<script src="${pageContext.request.contextPath }/plugins/jQuery/jquery.min.js"></script>
<script src="${pageContext.request.contextPath }/plugins/jQuery/jquery.easyui.min.js"></script>
<script src="${pageContext.request.contextPath }/admin/js/reg.js"></script>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/admin/css/input1.css"/>
<script>
	$(function(){
//		$.messager.alert('系统消息','子栏目删除成功！');
		// 区域负责人下拉列表
		$('#chargeUser').combobox({
			valueField:'userid',
			textField:'username',
			url:'${pageContext.request.contextPath }/admin/user/listUserByRole/2'
		});
		$('#chargeUser').combobox("setValue",-1);
		
		// 站长下拉列表
		$('#sUser').combobox({
			valueField:'userid',
			textField:'username',
			url:'${pageContext.request.contextPath }/admin/user/listUserByRole/3'
		});
		$('#sUser').combobox("setValue",-1);
		
		// 站点类型下拉列表
		$('#stationKind').combobox({
			valueField:'value',
			textField:'text',
			data:[{"value":"1","text":"提货仓"},
				{"value":"2","text":"中心仓"}
			]
		});
		$('#stationKind').combobox("setValue",1);
		
		// 站点市场类型
		$('#stationType').combobox({
			valueField:'value',
			textField:'text',
			data:[{"value":"1","text":"普通市场"},
				{"value":"2","text":"二批市场"},
				{"value":"3","text":"虚拟仓"},
				{"value":"4","text":"卫星城市站"},
				{"value":"5","text":"蒜米专供"}
			]
		});
		$('#stationType').combobox("setValue",1);
		
		// 站点属性下拉列表
		$('#stationProperty').combobox({
			valueField:'dict_code',
			textField:'dict_name',
			url:'${pageContext.request.contextPath }/admin/station/findStationProperty'
		});
		$('#stationProperty').combobox("setValue","-1");
		
		$('#fb').filebox({ 
		 	buttonText: '请选择文件', 
		 	buttonAlign: 'right',
		 	editable:false 
		});
		$("a[name='qsave']").linkbutton({text:'保存站点信息',plain:true,iconCls:'icon-ok'});
		$('#init_pass').textbox('setValue',getRandomPass());//赋值
		$("#init_pass").textbox('readonly',true);//设置只读 
	});
	
	// 得到6位数字的随机密码
	function getRandomPass(){
		var pass="";
		for(var i=0;i<6;i++){
			pass=pass+Math.ceil(Math.random()*(10)-1);
		}
		return pass;
	}
	
	function doSub(){
		var sname=$('#sname').val();
		if($.trim(sname)==''){
			$.messager.alert('系统消息','<span style="color:red;">站点名称必须输入！</span>');
			$('#sname').textbox('textbox').focus(); 
    		return;
		}
		var chargeUser=$('#chargeUser').combobox("getValue");
		if(chargeUser==-1){
			$.messager.alert('系统消息','<span style="color:red;">区域负责人必须选择！</span>');
			return;
		}
		var sUser=$('#sUser').combobox("getValue");
		if(sUser==-1){
			$.messager.alert('系统消息','<span style="color:red;">站长姓名必须选择！</span>');
			return;
		}
		var stationKind=$('#stationKind').combobox("getValue");
		if(stationKind==-1){
			$.messager.alert('系统消息','<span style="color:red;">站点类型必须选择！</span>');
			return;
		}
		var stationType=$('#stationType').combobox("getValue");
		if(stationType==-1){
			$.messager.alert('系统消息','<span style="color:red;">站点市场类型必须选择！</span>');
			return;
		}
		var stationProperty=$('#stationProperty').combobox("getValue");
		if(stationProperty==-1){
			$.messager.alert('系统消息','<span style="color:red;">站点市场属性必须选择！</span>');
			return;
		}
		$('#addStation').submit();
	}
</script>
</head>

<body>
<form method="post" id="addStation" action="${pageContext.request.contextPath }/admin/station/addStation" enctype="multipart/form-data">
<div class="i-container" style="width:1000px;">
	<div class="i-common i-title">添加新站点信息
		<span style="color:red; margin-left:30px;">${addMsg }</span>
		<div class="i-btn"><a id="btn" href="javascript:doSub()" name="qsave"></a></div><div style=" clear:both;"></div>
	</div>
    <!--
	<div class="i-common i-title-left" width="200">中国人民欢迎您！</div><div class="i-common i-title-right">右边的标题</div>
    -->
    <div class="i-common i-cnt-left">站点名称：</div><div class="i-common i-cnt-right">
    	<input name="station.STATION_NAME" id="sname" class="easyui-textbox" style="width:210px;height:26px"/>
    </div>
    <div class="i-common i-cnt-middle">站点地址：</div>
    <div class="i-common i-cnt-right">
    	<input name="station.STATION_ADDRESS" id="sname" class="easyui-textbox" style="width:210px;height:26px"/>
    </div>
    <div class="i-common i-cnt-middle">区域负责人：</div>
    <div class="i-common i-cnt-right">
    	<input name="station.AREA_CHARGE" id="chargeUser" class="easyui-textbox" style="width:210px;height:26px"/>
    </div>
    <div style="clear:both;"></div>
    <div class="i-common i-cnt-left">站长姓名：</div>
    <div class="i-common i-cnt-right">
    	<input name="station.STATION_MASTER" id="sUser" class="easyui-textbox" style="width:210px;height:26px"/>
    </div>
    <div class="i-common i-cnt-middle">站长头像：</div>
    <div class="i-common i-cnt-right">
    	
    	<input class="easyui-filebox" id="fb" name="img" data-options="prompt:'请选择图片...'" style="width:210px;height:26px"/>
    </div>
    <div class="i-common i-cnt-middle">站点类型：</div>
    <div class="i-common i-cnt-right">
    	<input name="station.STATION_KIND" id="stationKind" class="easyui-textbox" style="width:210px;height:26px"/>
    </div>
    <div style="clear:both;"></div> 
    <div class="i-common i-cnt-left">站点投诉电话：</div>
    <div class="i-common i-cnt-right">
		<input name="station.REPORT_PHONE" id="sname" class="easyui-textbox" style="width:210px;height:26px"/>
	</div>
    <div class="i-common i-cnt-middle">市场类型：</div>
    <div class="i-common i-cnt-right">
    	<input name="station.STATION_TYPE" id="stationType" class="easyui-textbox" style="width:210px;height:26px"/>
    </div>
    <div class="i-common i-cnt-middle">市场属性：</div>
    <div class="i-common i-cnt-right">
    	<input name="station.STATION_PROPERTY" id="stationProperty" class="easyui-textbox" style="width:210px;height:26px"/>
    </div>
    <div style="clear:both;"></div>
    <div class="i-common i-cnt-left">通用初始密码：</div>
    <div class="i-common i-cnt-right">
		<input name="station.INIT_PASSWORD" id="init_pass" class="easyui-textbox" style="width:210px;height:26px"/>
	</div>
    <div class="i-common i-cnt-middle">需到货时间：</div>
    <div class="i-common i-cnt-right">
    	<input name="station.SEND_TIME" id="init_pass" class="easyui-textbox" style="width:210px;height:26px"/>
    </div>
    <div class="i-common i-cnt-middle">&nbsp;</div>
    <div class="i-common i-cnt-right">
    	&nbsp;
    </div>
    <div style="clear:both;"></div>
</div>

</form>
</body>
</html>
